package com.icoolkj.mall.user.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
import org.springframework.cloud.client.loadbalancer.RestTemplateCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author icoolkj
 * @version 1.0
 * @description
 * @createDate 2025/01/16 18:51
 */
@Configuration
public class RestTemplateConfig {

    @LoadBalanced
    @Bean
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }


//    @Bean
//    public RestTemplate restTemplate(LoadBalancerInterceptor loadBalancerInterceptor) {
//        RestTemplate restTemplate = new RestTemplate();
//        //注入loadBalancerInterceptor拦截器（具有负载均衡的能力）
//        restTemplate.setInterceptors(Arrays.asList(loadBalancerInterceptor));
//        return restTemplate;
//    }


}
